 package tf_rna_hit;

public class Bedlnc {
	private String name;
	private int start;
	private int end;
	private String strand;
	private String chr;
	private int tss;
	private int blockstart;
	private int blockend;
	
	// constructors
	public Bedlnc(){
		this.name = null;
		this.start = 0;
		this.end = 0;
		this.strand = null;
		this.chr = null;
		this.tss = 0;
	}
	
	public Bedlnc(String chr, int start, int end, String name, int tss, String strand){
		setChr(chr);
		setStart(start);
		setName(name);
		setEnd(end);
		setTss(tss);
		setStrand(strand);
		setBlock(tss);
	}
	
	public Bedlnc(String chr, int start, int end, String name, int tss, String strand, int shang, int xia){
		setChr(chr);
		setStart(start);
		setName(name);
		setEnd(end);
		setTss(tss);
		setStrand(strand);
		setBlock(shang, xia);
	}
	// setters
	public void setName(String name){
		this.name = name;
	}
	
	public void setChr(String chr){
		this.chr = chr;
	}
	
	public void setStart(int start){
		this.start = start;
	}
	
	public void setEnd(int end){
		this.end = end;
	}
	
	public void setTss(int tss){
		this.tss = tss;
	}
	
	public void setStrand(String strand){
		this.strand = strand;
	}
	
	
	public void setBlock(int tss){
		if(this.strand.equals("-")){
			this.blockstart  = tss - 1000;
			this.blockend  = tss + 5000 ;
		}else{
			this.blockstart = tss - 5000;
			this.blockend = tss + 1000;
		}
	}
	
	// 这个setBlock是用来调整所有的block的，针对需要调整匹配范围的情况
	public void setBlock(int shang, int xia){
		if(this.strand.equals("-")){
			this.blockend =  this.tss  +  shang;
			this.blockstart =this.tss - xia;
		}else{
			this.blockstart = this.tss - shang;
			this.blockend = this.tss + xia;
		}
	}
	
	// getters
	public String getName(){
		return this.name;
	}
	
	public String getStrand(){
		return this.strand;
	}
	
	public int getStart(){
		return this.start;
	}
	
	public int getEnd(){
		return this.end;
	}
	
	public String getChr(){
		return this.chr;
	}
	
	public int getTss(){
		return this.tss;
	}
	
	public String getBlock(){
		return this.blockstart + "-" + this.blockend;
	}
	
	public int getBlockstart(){
		return this.blockstart;
	}
	
	public int getBlockend(){
		return this.blockend;
	}
	
	public String test(){
		return this.chr + this.start + this.end + this.name + this.tss + this.strand;
	}
	

	// 输出bed格式
	public String printBed(){
		return this.chr + "\t" + this.start + "\t" + this.end + "\t" + this.name + "\t" + this.tss + "\t" + this.strand;
	}
}
